make build reproducible
authorBernhard M. Wiedemann <githubbmw@lsmod.de>
Tue, 17 Jan 2017 14:53:45 +0000 (14:53 +0000)
committerBernhard M. Wiedemann <bwiedemann@suse.de>
Fri, 20 Jan 2017 13:09:58 +0000 (14:09 +0100)
by allowing build systems to use a constant date instead of the current one
see https://reproducible-builds.org/ for why this is good

This call is designed to work with both GNU date and BSD date implementations

Makefile.in

index c2b62df16dce75837bc90e8f3cfed854cb05496e..23b341bdc7b3568cc709a190bd70cd5030f10a04 100644 (file)
@@ -22,7 +22,8 @@ CFG_RELEASE=$(CFG_RELEASE_NUM)-dev
 CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev
 endif
 
-CFG_BUILD_DATE = $(shell date +%F)
+# allow build systems to use a constant date instead of the current one
+CFG_BUILD_DATE = $(shell SOURCE_DATE_EPOCH="$${SOURCE_DATE_EPOCH:-$$(date +%s)}" ; date -u -d "@$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u -r "$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u +%F)
 
 ifeq ($(wildcard $(CFG_SRC_DIR)/.git),)
 CFG_VERSION = $(CFG_RELEASE) (built $(CFG_BUILD_DATE))